// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Fluent;
using Elastic.Clients.Elasticsearch.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Rollup;

public sealed partial class FieldMetric
{
	/// <summary>
	/// <para>The field to collect metrics for. This must be a numeric of some kind.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("field")]
	public Elastic.Clients.Elasticsearch.Field Field { get; set; }

	/// <summary>
	/// <para>An array of metrics to collect for the field. At least one metric must be configured.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("metrics")]
	public ICollection<Elastic.Clients.Elasticsearch.Rollup.Metric> Metrics { get; set; }
}

public sealed partial class FieldMetricDescriptor<TDocument> : SerializableDescriptor<FieldMetricDescriptor<TDocument>>
{
	internal FieldMetricDescriptor(Action<FieldMetricDescriptor<TDocument>> configure) => configure.Invoke(this);

	public FieldMetricDescriptor() : base()
	{
	}

	private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; }
	private ICollection<Elastic.Clients.Elasticsearch.Rollup.Metric> MetricsValue { get; set; }

	/// <summary>
	/// <para>The field to collect metrics for. This must be a numeric of some kind.</para>
	/// </summary>
	public FieldMetricDescriptor<TDocument> Field(Elastic.Clients.Elasticsearch.Field field)
	{
		FieldValue = field;
		return Self;
	}

	/// <summary>
	/// <para>The field to collect metrics for. This must be a numeric of some kind.</para>
	/// </summary>
	public FieldMetricDescriptor<TDocument> Field<TValue>(Expression<Func<TDocument, TValue>> field)
	{
		FieldValue = field;
		return Self;
	}

	/// <summary>
	/// <para>The field to collect metrics for. This must be a numeric of some kind.</para>
	/// </summary>
	public FieldMetricDescriptor<TDocument> Field(Expression<Func<TDocument, object>> field)
	{
		FieldValue = field;
		return Self;
	}

	/// <summary>
	/// <para>An array of metrics to collect for the field. At least one metric must be configured.</para>
	/// </summary>
	public FieldMetricDescriptor<TDocument> Metrics(ICollection<Elastic.Clients.Elasticsearch.Rollup.Metric> metrics)
	{
		MetricsValue = metrics;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		writer.WritePropertyName("field");
		JsonSerializer.Serialize(writer, FieldValue, options);
		writer.WritePropertyName("metrics");
		JsonSerializer.Serialize(writer, MetricsValue, options);
		writer.WriteEndObject();
	}
}

public sealed partial class FieldMetricDescriptor : SerializableDescriptor<FieldMetricDescriptor>
{
	internal FieldMetricDescriptor(Action<FieldMetricDescriptor> configure) => configure.Invoke(this);

	public FieldMetricDescriptor() : base()
	{
	}

	private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; }
	private ICollection<Elastic.Clients.Elasticsearch.Rollup.Metric> MetricsValue { get; set; }

	/// <summary>
	/// <para>The field to collect metrics for. This must be a numeric of some kind.</para>
	/// </summary>
	public FieldMetricDescriptor Field(Elastic.Clients.Elasticsearch.Field field)
	{
		FieldValue = field;
		return Self;
	}

	/// <summary>
	/// <para>The field to collect metrics for. This must be a numeric of some kind.</para>
	/// </summary>
	public FieldMetricDescriptor Field<TDocument, TValue>(Expression<Func<TDocument, TValue>> field)
	{
		FieldValue = field;
		return Self;
	}

	/// <summary>
	/// <para>The field to collect metrics for. This must be a numeric of some kind.</para>
	/// </summary>
	public FieldMetricDescriptor Field<TDocument>(Expression<Func<TDocument, object>> field)
	{
		FieldValue = field;
		return Self;
	}

	/// <summary>
	/// <para>An array of metrics to collect for the field. At least one metric must be configured.</para>
	/// </summary>
	public FieldMetricDescriptor Metrics(ICollection<Elastic.Clients.Elasticsearch.Rollup.Metric> metrics)
	{
		MetricsValue = metrics;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		writer.WritePropertyName("field");
		JsonSerializer.Serialize(writer, FieldValue, options);
		writer.WritePropertyName("metrics");
		JsonSerializer.Serialize(writer, MetricsValue, options);
		writer.WriteEndObject();
	}
}